// SPDX-FileCopyrightText: 2023-2025 Sangfor Technologies Inc.
// SPDX-License-Identifier: Mulan PSL v2
package resource

import (
	"os"
	"testing"

	. "github.com/smartystreets/goconvey/convey"

	"code.geniusai.org/notebook-manager/pkg/config"
)

var manager *Manager

func getTestManager() *Manager {
	if manager != nil {
		return manager
	}
	conf := &config.Conf{
		Mysql: config.MysqlConf{
			User:   "root",
			Passwd: "sangfor",
			Url:    "10.59.14.114",
			Port:   "32006",
			DbName: "aip",
			Args:   "charset=utf8mb4&parseTime=True&loc=Local",
		},
	}
	// set env
_:
	os.Setenv("KUBERNETES_SERVICE_HOST", "10.59.14.111")
_:
	os.Setenv("KUBERNETES_SERVICE_PORT", "6443")
	ret := NewManager(conf)
	if err := ret.Init(); err != nil {
		panic(err)
	}
	manager = ret
	return manager
}

func Test(t *testing.T) {

	Convey("newManager", t, func() {
		manager := getTestManager()
		So(manager, ShouldNotEqual, nil)
	})
}
